package com.jing.spring_boot_demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;


import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
public class SpringBootDemoApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext run = SpringApplication.run(SpringBootDemoApplication.class, args);
        String ip = InetAddress.getLocalHost().getHostAddress();
        Environment environment = run.getEnvironment();
        String port = environment.getProperty("server.port");
        String path = environment.getProperty("server.servlet.context-path");
        if (path == null) path = "";

        System.out.println("\n----------------------------------------------------------\n\t" +
                "测试服务--启动成功! Access URLs:\n\t" +
                "Local访问网址: \t\thttp://localhost:" + port + path + "\n\t" +
                "External访问网址: \thttp://" + ip + ":" + port + path + "\n\t" +
                "接口文档: \thttp://" + ip + ":" + port + path + "/" + "doc.html\n\t" +
                "----------------------------------------------------------");

    }

}
